package com.guchenbo.example.socket.bio;

import javax.net.ServerSocketFactory;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Author gucb
 * @Date 15/09/2017.
 */
public class HttpServer {
    public static void main(String[] args) {
        try {
            ServerSocketFactory socketFactory = ServerSocketFactory.getDefault();
            ServerSocket serverSocket = socketFactory.createServerSocket(8889);

            Socket socket = serverSocket.accept();
            InputStream inputStream = socket.getInputStream();
            OutputStream outputStream = socket.getOutputStream();

            String s = "hello world";
            outputStream.write(s.getBytes());
            outputStream.flush();
            socket.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
